<!doctype html>
<!--[if gt IE 8]><!-->
<html class="no-js" lang="">
	<!--<![endif]-->
	<head>
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<title>学生端课程信息</title>
		<meta name="description" content="Ela Admin - HTML5 Admin Template">
		<meta name="viewport" content="width=device-width, initial-scale=1">

		<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/normalize.css@8.0.0/normalize.min.css">
		<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.1.3/dist/css/bootstrap.min.css">
		<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/css/font-awesome.min.css">
		<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/lykmapipo/themify-icons@0.1.2/css/themify-icons.css">
		<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/pixeden-stroke-7-icon@1.2.3/pe-icon-7-stroke/dist/pe-icon-7-stroke.min.css">
		<link rel="stylesheet" href="assets/css/cs-skin-elastic.css">
		<link rel="stylesheet" href="assets/css/lib/datatable/dataTables.bootstrap.min.css">
		<link rel="stylesheet" href="assets/css/style.css">

		<!-- <script type="text/javascript" src="https://cdn.jsdelivr.net/html5shiv/3.7.3/html5shiv.min.js"></script> -->
		<!--引入Vue-->
		<script src="assets/js/vue.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="https://cdn.bootcdn.net/ajax/libs/axios/0.20.0/axios.min.js"></script>
		<script src="https://cdn.jsdelivr.net/npm/lodash@4.13.1/lodash.min.js"></script>
		
	</head>
	<body>
		<!-- Left Panel -->

		<aside id="left-panel" class="left-panel">
			<nav class="navbar navbar-expand-sm navbar-default">
			
					<div id="main-menu" class="main-menu collapse navbar-collapse">
						<ul class="nav navbar-nav">
			
							<li class="menu-title">菜单</li><!-- /.menu-title -->
							<li>
								<a href="stu-dataOfClass.html"> <i class="menu-icon fa fa-users"></i>班级 </a>
							</li>
							<li>
								<a href="stu-dataOfHomeworkinfo.html"> <i class="menu-icon fa fa-file-word-o"></i>已提交作业信息 </a>
							</li>
							<li>
								<a href="stu-dataOfHomeworktask.html"> <i class="menu-icon fa fa-file-word-o"></i>未完成的课堂任务 </a>
							</li>
							<li class="menu-title">退出</li><!-- /.menu-title -->
							<li>
								<a href="login.html"> <i class="menu-icon fa fa-user-o"></i>退出登录 </a>
							</li>
						</ul>
					</div><!-- /.navbar-collapse -->
				</nav>
		</aside><!-- /#left-panel -->

		<!-- Left Panel -->

		<!-- Right Panel -->

		<div id="right-panel" class="right-panel">

			<!-- Header-->
			<header id="header" class="header">
				<div class="top-left">
					<div class="navbar-header">
						<a class="navbar-brand" href="#"><i class="menu-icon fa fa-user-circle fa-2x"></i></a>
					</div>
				</div>

			</header><!-- /header -->
			<!-- Header-->

			<div class="breadcrumbs">
				<div class="breadcrumbs-inner">
					<div class="row m-0">


					</div>
				</div>
			</div>

			<div class="content">
				<div class="animated fadeIn">
					<div class="row">

						<div class="col-md-12">
							<div class="card">
								<div class="card-header">
									<strong class="card-title">作业提交信息(注：仅显示已提交作业，如果教师没有评判则当前成绩无效，教师批改后无法更改.)</strong>
										
								</div>
								<div class="card-body" id="tby">
									<table id="bootstrap-data-table" class="table table-striped table-bordered">
										<!--add element here-->
										<!--这里是选择分页-->
										<!--数据段-->
										 <span class="badge badge-info">当前选择的班级是：{{currentclass}}</span>
										<thead>
											<tr>
												<th>#</th>
												<th>作业名</th>
												<th>作业轮数</th>
												<th>教师评语</th>
												<th>上次提交时间</th>
												<th>教师是否已经评判</th>
												<th>作业分数</th>
												<th>下载作业</th>
												<th>删除作业</th>
												<th>修改作业</th>
											</tr>
										</thead>
										<tbody >
											<tr v-for="(item,index) in homeworkinfos">
												<td>{{index+1}}</td>
												<td>{{item.title}}</td>
												<td>{{item.number}}</td>
												<td>{{item.comment}}</td>
												<td>{{item.times}}</td>
												<td>{{item.staus}}</td>
												<td>{{item.score}}</td>
												<td>
													<input  class="btn btn-primary" type="button" value="Download" @click="Downloadmyhw(index)">
												</td>
												<td>
													<input v-show="item.staus=='是'" class="btn btn-danger" type="button" value="Delete" disabled="disabled">
													<input v-show="item.staus=='否'" class="btn btn-danger" type="button" value="Delete" @click="DeleteHw(item.staus,item.number,index)">
													
												</td>
												<td>
													<input  v-show="item.staus=='是'" class="btn btn-success" type="button" value="Modify"  disabled="disabled" >
													<input v-show="item.staus=='否'"  class="btn btn-success" type="button" value="Modify" @click="ModifyHw(item.write,item.number,index)">
												</td>
											</tr>
										</tbody>


									</table>
									<!--
									<div class="row" id="pages">
										<div class="col-sm-12 col-md-5">
											<div class="dataTables_info" id="bootstrap-data-table_info" role="status" aria-live="polite">
												Showing {{pages.beginPages}} to {{pages.endPages}} of {{pages.sumPages}} entries
											</div>
										</div>
										<div class="col-sm-12 col-md-7">
											<div class="dataTables_paginate paging_simple_numbers" id="bootstrap-data-table_paginate">
												<ul class="pagination">
													<li class="paginate_button page-item previous disabled" id="bootstrap-data-table_previous">
														<a href="#" aria-controls="bootstrap-data-table" data-dt-idx="0" tabindex="0" class="page-link">
															Previous
														</a>
													</li>
													<li class="paginate_button page-item active">
														<a href="#" aria-controls="bootstrap-data-table" data-dt-idx="1" tabindex="0" class="page-link">
															1
														</a>
													</li>
													<li class="paginate_button page-item next disabled" id="bootstrap-data-table_next">
														<a href="#" aria-controls="bootstrap-data-table" data-dt-idx="2" tabindex="0" class="page-link">
															Next
														</a>
													</li>
												</ul>
											</div>
										</div>
									</div>
									
									-->
								</div>
							</div>
						</div>


					</div>
				</div><!-- .animated -->
			</div><!-- .content -->


			<!-- /#right-panel -->

			<!-- Right Panel -->

			<!-- Scripts -->
			<!--
    <script src="https://cdn.jsdelivr.net/npm/jquery@2.2.4/dist/jquery.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/popper.js@1.14.4/dist/umd/popper.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@4.1.3/dist/js/bootstrap.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/jquery-match-height@0.7.2/dist/jquery.matchHeight.min.js"></script>
    <script src="assets/js/main.js"></script> -->

			<!--
     
    <script src="assets/js/lib/data-table/dataTables.bootstrap.min.js"></script> 
    <script src="assets/js/lib/data-table/dataTables.buttons.min.js"></script> 
    <script src="assets/js/lib/data-table/buttons.bootstrap.min.js"></script> 
      
    
    <script src="assets/js/lib/data-table/buttons.html5.min.js"></script> 
    <script src="assets/js/lib/data-table/buttons.print.min.js"></script> 
    <script src="assets/js/lib/data-table/buttons.colVis.min.js"></script> 
    <script src="assets/js/init/datatables-init.js"></script>

-->
			<script>
				let vm2 = new Vue({
					el: '#tby',
					data: {
						homeworkinfos: [
						],
						currentclass:window.localStorage.getItem('SselectClassName')
						
					},
					watch:{
						homeworkinfos:function(val){
							this.getAnswer();
						}
					},
					mounted(){
						this.GetNewPages();
					},
					methods: {
						getAnswer(){
							//获取已做作业的number
							var username1 = window.localStorage.getItem('SUsername');
							var cid1 = window.localStorage.getItem('SselectClass');
							
							axios.get(
									'http://172.81.214.138:8000/student_work_number?username='+username1+'&classid='+cid1)
								//成功返回
								.then(response => {
									console.log('work_number:');
									console.log(response);
									if(response.data.state==1){
										/*
										var j=0;
										for(var i=0; i<this.homeworkinfos.length;i++){ // 添加disable属性并设置为false
												if(this.homeworkinfos[i].number==response.data.data.finishwork[j]){
										          this.$set(this.homeworkinfos[i], 'write', '已交');j++;}
												else{
												  this.$set(this.homeworkinfos[i], 'write', '未交');}
										        }*/
										//console.log(response);
										return;
									}
									else{
										alert('获取失败！');
										return;
									}
								})
								//失败返回
								.catch(error => {
									console.log(error);
								})
						},
						GetNewPages(){
							var username = window.localStorage.getItem('SUsername');
							var cid = window.localStorage.getItem('SselectClass');	
							axios.get(
									'http://172.81.214.138:8000/job_search?username='+username+'&classid='+cid+'&order='+7)
								//成功返回
								.then(response => {
									console.log(response);
									if(response.data.state==1){
										
												//console.log(response);
												
										this.homeworkinfos=response.data.data.data;
										this.homeworkinfos.forEach(
											list=>{
												if(list.staus==1)
												list.staus='是'
												else
												list.staus='否'
											}
										)
										//console.log(this.homeworkinfos);
										this.flag=1;
										
									}
									else{
										alert('登录失败！');
										return;
									}
								})
								//失败返回
								.catch(error => {
									console.log(error);
								})	
								
						},
						ModifyHw(write,number,jid){
							//window.localStorage.setItem('hwwrite',write);
							console.log(this.homeworkinfos[jid]);
							if(this.homeworkinfos[jid].staus=='否'){
							window.localStorage.setItem('number',number);
							window.localStorage.setItem('jobid',this.homeworkinfos[jid].jid);
							window.location.assign('stu-dataOfHomeworkgit.html');
							window.localStorage.setItem('ist',0);
							}
							else{
								//什么也不做
							}
						},
						DeleteHw(status,number,index){
							if(status=='否'){
								//
								axios.get(
										'http://172.81.214.138:8000/job_delete?jobid='+this.homeworkinfos[index].jid)
									//成功返回
									.then(response => {
										alert('删除成功');
										this.GetNewPages();
										console.log(response);
									})
									//失败返回
									.catch(error => {
										alert('删除成功');
										console.log(error);
									})
							}else{
								alert('你不能删除已经改过的作业！');
							}
						},
						Downloadmyhw(index){
							var jobid=this.homeworkinfos[index].jid;
							var urls='http://172.81.214.138:8000/job_download?jobid='+jobid ;
							console.log(urls);
							window.location.assign(urls);
							
						}
						
					}
				})
			</script>
			<!--
			<script type="text/javascript">
				let vm = new Vue({
					el: '#pages',
					data: {
						pages: { //翻页
							beginPages: 1,
							endPages: 2,
							sumPages: 3
						}
					},
					methods: {}
				})
			</script>
			-->

	</body>
</html>
